package 图书系统.user.operation;

import 图书系统.user.book.BookList;

import java.util.Scanner;

public class ReturnOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        //查找书籍
        System.out.println("<归还书籍>");
        IOperation showOperation=new ShowOperation();
        showOperation.work(bookList);
        System.out.println("请输入你要归还的书名");
        Scanner scanner=new Scanner(System.in);
        String name=scanner.nextLine();
        int i;
        for (i = 0; i < bookList.getCount(); i++) {
            if(name.equals(bookList.getArr(i).getName())){
                break;
            };
        }
        if(i>=bookList.getCount()){
            System.out.println("未查询到！");
        }else {
            if(bookList.getArr(i).isBorrow()==true){
                System.out.println("归还成功");
                //修改状态
                bookList.getArr(i).setBorrow(false);
            }else {
                System.out.println("该书一直在书籍里，不需要归还");
            }
        }
    }
}
